import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

class Student implements Comparable<Student>{
    public String name;
    public int age;
    public double achievement;

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    @Override
    public int compareTo(Student o) {
        return (int)(this.achievement-o.achievement);
    }

    public  Student(String name, int age, double achievement) {//带三个参数的构造方法
        this.name = name;
        this.age = age;
        this.achievement = achievement;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setAchievement(double achievement) {
        this.achievement = achievement;
    }

    public double getAchievement() {
        return achievement;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", achievement=" + achievement +
                '}';
    }
}
public class Test {
    public static void main1(String[] args) {
        ArrayList<Student>arrayList=new ArrayList<>(3);
       arrayList.add(new Student("张三",21,100));
       arrayList.add(new Student("陈总",21,89));
       arrayList.add(new Student("三三",29,99));
        for (Student a:arrayList
             ) {System.out.println(a);

        }
        System.out.println("===================");
        Collections.sort(arrayList);
        for (Student a:arrayList
        ) {System.out.println(a);

        }
    }
























}
